import java.util.Arrays;

public class MyStack {
    int[] array;
    int useSize;

    public MyStack() {
        array = new int[10];
        useSize = 0;
    }
    public void push(int element) {
        if(isFull()) {
            array = Arrays.copyOf(array,2*array.length);
        }
        array[useSize++] = element;
    }
    public int pop() {
        int val = peek();
        useSize--;
        return val;
    }
    public int peek() {
        if(isEmpty()) {
            throw new EmptyException("当前栈是空的");
        }
        return array[useSize-1];
    }
    public int getUseSize() {
        return useSize;
    }
    private boolean isEmpty() {
        return useSize == 0;
    }
    private boolean isFull() {
        return array.length == useSize;
    }
}
